<template>
    <div>
    	<div class="graybg"></div>
		<div class="header header_bg">
  			<div class="header_left">
  				<i onclick="javascript:history.back(-1)" class="iconfont baiColor">&#xe612;</i>
  			</div>
  			<div class="header_center">
  				<span class="baiColor">支付密码</span>
  			</div>
  		</div>

  		<div class="center">
  			<form action="" method="post" style="padding-top: 52px;">
  			<input type="password"  placeholder="支付密码" v-model="pass" value="" />
 
  			<input type="password"  placeholder="确认支付密码" v-model="surepass" value="" />
  		</form>
 <!--to="iIndex"-->
  		<button @click="updatepass">确定</button>

  		</div>
  		
    </div>

</template>


<script>
    export default{
        data(){
            return {
				pass:'',
				surepass:'',
            }
        },
        methods:{
        	//通过id进来的
        	updatepass:function(){
        		var _this = this;
				const info = window.localStorage.data;
        		var str=window.location.href;
				var num=str.lastIndexOf("/")+1;
				var id = str.substring(num)
				if(_this.pass == "" || _this.surepass == ""){
					alert("请将信息填写完整")
				}else if(_this.pass != _this.surepass){
					alert("两次密码输入不一致，请重新输入")
				}else if(_this.pass === _this.surepass){
					let params = new URLSearchParams();
					params.append('token', info);	//客户秘钥（信息）
					params.append('pwd',_this.surepass);
					params.append('mOrderId',id);
					this.$axios({
					   url:"Home/Money/money_pwd_validate",
						method:"post",
						data:params
					  }).then(function(res){
						if(res.data.code == 1){
							alert("支付成功")
							_this.$router.push("wShares");
						}else if(res.data.code == 2){
							alert("支付失败")
						}else if(res.data.code == 4){
							alert("密码错误")
							_this.pass = "";
							_this.surepass = "";
						}else if(res.data.code == 5){
							alert("转账订单未找到")
						}else if(res.data.code == 6){
							alert("订单重复交易")
						}else if(res.data.code == 7){
							alert("余额不足")
						}
					}).catch(function(err){
						console.log(err)		
					})
				}
        	}
        },
    }

</script>

<style scoped="scoped">
@import "../css/public.css";
.center{
	width: 95%;
	margin: 0 auto;
}
.center form{
	width: 100%;
}
.center form input{
	padding-left: 10px;
	display: block;
	background: #FFFFFF;
	height: 14px;
	width: 97%;
	margin: 10px 0;
	height: 40px;
	line-height: 38px;
}

input::-webkit-input-placeholder{
	color: #999;
	font-size: 14px;
	line-height: 38px;
}
.center button{
	background: #F3961F;
	width: 100%;
	height: 45px;
	border-radius: 10px;
	font-size: 18px;
	color: #FCFCFC;
	margin-top:128px;
}
</style>
